package net.discard.model.domian;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jdk.nashorn.internal.objects.annotations.Getter;
import jdk.nashorn.internal.objects.annotations.Setter;

/**
 * @Author: Discard
 * @Date: 2021/2/4 6:26 下午
 */
public class ResponseVo {

    private int code;
    private String message;
    private Object data;

    public ResponseVo() {
        this.code = 0;
        this.message = "SUCCESS";
    }

    public ResponseVo(Object data){
        this.code = 0;
        this.message = "SUCCESS";
        this.data = data;
    }

    public ResponseVo(int code, String message){
        this.code = code;
        this.message = message;
    }

    public static <T> ResponseVo SUCCESS(T data){
        return new ResponseVo(data);
    }

    public static <T> ResponseVo FAILED(String msg){
        return new ResponseVo(-1, msg);
    }

    public ResponseVo data(Object data){
        return new ResponseVo(data);
    }

    public String toString(){
        return JSON.toJSONString(this);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
